package ex.datastream.connectors;


import ex.datastream.functions.function.FilterFunc;
import ex.vo.Person;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * 示例：基于集合读取数据源
 */
public class CollectionTest02 {

    public static void main(String[] args) throws Exception {
        final StreamExecutionEnvironment env =
                StreamExecutionEnvironment.getExecutionEnvironment();

        List<Person> people = new ArrayList<>();
        people.add(new Person("Fred", 35));
        people.add(new Person("Wilma", 35));
        people.add(new Person("Pebbles", 2));

        DataStream<Person> dataStream = env.fromCollection(people);

//        DataStreamSource<Integer> dataStream2 = env.fromCollection(Arrays.asList(1, 2, 3, 4, 5, 6));
        DataStream<Person> personDataStream = dataStream.filter(new FilterFunc());

        System.out.println("fromCollection创建的DataStream并行度为：" + dataStream.getParallelism());

        personDataStream.print();
        env.execute();
    }


}